$('form').on('submit', function(e) {
    e.preventDefault();
    var data = $(this).serialize();
    $.ajax({
        type: 'post',
        url: '/my/updatepwd',
        data: data,
        success: function(a) {
            layer.msg(a.message);
            if (a.status === 0) {
                $('form')[0].reset();
            }
        }
    })
});
let form = layui.form;
form.verify({
    len: [
        /^[\S]{6,12}$/, '密码必须6到12位，且不能出现空格'
    ],
    diff: function(a) {
        let oldPwe = $('input[name=oldPwd]').val();
        if (oldPwe === a) {
            return '新密码不能和原密码相同'
        }
    },
    same: function(b) {
        let pwd = $('input[name=newPwd]').val();
        if (pwd !== b) {
            return '怎么密码不一样'
        }
    }
});